package com.yy.design.pattern.chain.of.responsibility;

public abstract class AbstractChainHandler {
    private AbstractChainHandler nextHandler;

    public AbstractChainHandler setNextHandler(AbstractChainHandler nextHandler) {
        this.nextHandler = nextHandler;
        return nextHandler;
    }

    public abstract void handle(ChainHandlerContext handlerContext);

    protected void invokeNextHandler(ChainHandlerContext handlerContext) {
        if (nextHandler != null) {
            nextHandler.handle(handlerContext);
        }
    }
}
